package com.jz.reservoirattributesclass.mapper;

import com.jz.legalpersonclass.model.LegalPersonVo;
import com.jz.planclass.model.PlanClassVo;
import com.jz.reservoirattributesclass.model.ReservoirattributesSelectVo;
import com.jz.reservoirattributesclass.model.ReservoirattributesVo;
import com.jz.subclass.model.SubClassVo;
import org.apache.ibatis.annotations.*;

import javax.validation.constraints.NotBlank;
import java.util.List;

/**
 * Created by WISE on 2021/12/26.
 */
@Mapper
public interface ReservoirattributesMapper {


    List<ReservoirattributesVo> queryData(ReservoirattributesSelectVo reservoirattributesSelectVo);

    int queryCount(ReservoirattributesSelectVo reservoirattributesSelectVo);

    @Select("select * from reservoirattributes where code = #{code}")
    ReservoirattributesVo queryByCode(String code);

    @Select("select * from reservoirattributes where name = #{name}")
    ReservoirattributesVo queryByName(String name);

    @Insert("insert into reservoirattributes(name,code,status,remark,createTime,createName)" +
            "values(#{name},#{code},#{status},#{remark},#{createTime},#{createName})")
    void add(ReservoirattributesVo classVo);

    @Select("select * from reservoirattributes where id = #{id}")
    List<ReservoirattributesVo> queryById(Integer id);

    @Select("select code subCode from subclass where subName = #{subName}")
    ReservoirattributesVo queryBySubName(@NotBlank(message = "备件小类名称不能为空") String subName);

    @Select("select code planCode from planclass where planName = #{planName}")
    ReservoirattributesVo queryByPlanName(@NotBlank(message = "备件小类名称不能为空") String planName);

    @Select("select *  from legalpersonclass where legalPersonName = #{legalPersonName}")
    LegalPersonVo queryByLegalName(@NotBlank(message = "法人名称不能为空") String legalPersonName);

    @Select("select legalPersonCode legalCode,legalPersonName legalName from legalpersonclass where userId = #{userId}")
    List<ReservoirattributesVo> queryByUserId(Integer userId);

    @Select("select * from subclass ")
    List<SubClassVo> queryAll();

    @Select("select * from planclass ")
    List<PlanClassVo> queryAll2();

    @Update("update reservoirattributes set name = #{name},updateTime = #{updateTime},updateName = #{updateName},remark = #{remark},code = #{code} where id = #{id}")
    int update(ReservoirattributesVo classVo);

    @Update("update reservoirattributes set status = #{status},updateTime = #{updateTime},updateName = #{updateName} where id = #{id}")
    void updateStatus(ReservoirattributesVo classVo);

    @Delete("delete from partlegal where partCode = #{code}")
    void delete(String code);

}
